package com.java2207.group1.controller;

import com.github.pagehelper.PageHelper;
import com.java2207.group1.common.LayuiPageVo;
import com.java2207.group1.common.R;
import com.java2207.group1.pojo.Aid;
import com.java2207.group1.service.AidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/aid")
public class AidController {

    @Autowired
    private AidService aidService;
    @RequestMapping("/aidPage")
    public LayuiPageVo<Aid> aidPageAll(@RequestParam Map<String,Object> map){
        LayuiPageVo<Aid> aidLayuiPageVo = aidService.aidPageAll(map);
        System.out.println(aidLayuiPageVo);
            return aidLayuiPageVo;

    }
    @RequestMapping("/delectAid")
    public R delectAid(int id){
       int delectAid = aidService.delectAid(id);
       if(delectAid!=0){
           return R.ok();
       }
            return R.error();
    }

    @RequestMapping("/aidAdd")
    public R addAid(Aid aid){
     int add = aidService.addAid(aid);
        if(add!=0){
            return  R.ok();
        }
            return  R.error();
    }
    @RequestMapping("/updateAid")
    public R updateAid(Aid aid){
        int update=aidService.updateAid(aid);
        if(update!=0){
            return R.ok();
        }
            return R.error();

    }
    @RequestMapping("/deleteAidIds")
    public R delectAidIds(String ids) {
        int i = aidService.delectAidId(ids);
        if (i != 0) {
            return R.ok();
        }
        return R.error();

    }
    }
